import { edpService } from "./decorators";
import express from 'express';
@edpService
class Service {
  static app: express.Express;
  static serviceName = 'ts-calc'
  static desc = 'a calculator in typescript'
  static category = 'test'
  static tasks = [
    'list_add_1: List<Int>->List<Int>',
    '#instant int_mul_2: Int->Int'
  ]
  updateProgress: any;
  log: any;
  list_add_1(inputs: object) {
    const arr = inputs as number[];
    for (let i = 0; i < arr.length; i++) {
      arr[i] += 1;
      setTimeout(() => {
        this.updateProgress(i / arr.length);
        this.log(`list_add_1: ${i} -> ${arr[i]}`);
      }, 1000);
    }
    return arr;
  }
  int_mul_2(inputs: object) {
    const val = inputs as unknown as number;
    return val * 2;
  }
}
Service.app.listen(3002, () => {
  console.log(`Server is running on port 3002.`);
});


